﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BestLifePOS_Core.Data.Fascade;
using BestLifePOS_Core.DomainObjects;

namespace BestLifePOS_PresentationLayer
{
    public partial class frmStock : Form
    {
          

        public frmStock()
        {
            InitializeComponent();
        }

            

        public void GridFillB()
        {
            DataTable GvStkData = new DataTable();

            DataTable GvStkData1 = new DataTable(); // branch table

            GvStkData.Columns.Add("Stock_Id");
            GvStkData.Columns.Add("Pro_Name");
            GvStkData.Columns.Add("Category");
            GvStkData.Columns.Add("Qty");
            GvStkData.Columns.Add("Reorder_Qty");
            GvStkData.Columns.Add("Reorder_Level");
      


            GvStkData1 = StockDAO.GetStockByBranchId(txtBranchId.Text);

            int counte = GvStkData1.Rows.Count;

            for (int i = 0; i <= counte - 1; i++)
            {
                // for branch
                GvStkData.Rows.Add(GvStkData.NewRow());
                GvStkData.Rows[GvStkData.Rows.Count - 1][0] = GvStkData1.Rows[i][0].ToString();
                GvStkData.Rows[GvStkData.Rows.Count - 1][1] = GvStkData1.Rows[i][1].ToString();
                GvStkData.Rows[GvStkData.Rows.Count - 1][2] = GvStkData1.Rows[i][2].ToString();
                GvStkData.Rows[GvStkData.Rows.Count - 1][3] = GvStkData1.Rows[i][3].ToString();
                GvStkData.Rows[GvStkData.Rows.Count - 1][4] = GvStkData1.Rows[i][4].ToString();
                GvStkData.Rows[GvStkData.Rows.Count - 1][5] = GvStkData1.Rows[i][5].ToString();
            }

            dataGridView2.DataSource = GvStkData;
        }

        public void GridFillP()
        {

            DataTable GvStkData2 = new DataTable(); // pro table

            DataTable GvStkDatax = new DataTable();


            GvStkDatax.Columns.Add("Stock_Id");
            GvStkDatax.Columns.Add("Pro_Name");
            GvStkDatax.Columns.Add("Category");
            GvStkDatax.Columns.Add("Qty");
            GvStkDatax.Columns.Add("Reorder_Qty");
            GvStkDatax.Columns.Add("Reorder_Level");


            GvStkData2 = StockDAO.GetStockByProId(txtpro1.Text);

            int counte2 = GvStkData2.Rows.Count;

            for (int i = 0; i <= counte2 - 1; i++)
            {
                //for pro
                GvStkDatax.Rows.Add(GvStkDatax.NewRow());
                GvStkDatax.Rows[GvStkDatax.Rows.Count - 1][0] = GvStkData2.Rows[i][0].ToString();
                GvStkDatax.Rows[GvStkDatax.Rows.Count - 1][1] = GvStkData2.Rows[i][1].ToString();
                GvStkDatax.Rows[GvStkDatax.Rows.Count - 1][2] = GvStkData2.Rows[i][2].ToString();
                GvStkDatax.Rows[GvStkDatax.Rows.Count - 1][3] = GvStkData2.Rows[i][3].ToString();
                GvStkDatax.Rows[GvStkDatax.Rows.Count - 1][4] = GvStkData2.Rows[i][4].ToString();
                GvStkDatax.Rows[GvStkDatax.Rows.Count - 1][5] = GvStkData2.Rows[i][5].ToString();

            }

            dataGridView2.DataSource = GvStkData2;
        }

     

        private void ShowAll_Click(object sender, EventArgs e)
        {              
            GridFillB();
           
        }

        private void btnShowAll_Click(object sender, EventArgs e)
        {
            GridFillP();
        }
        
        private void button17_Click(object sender, EventArgs e)
        {

        }
    }
}
